<?php

/**
 * Invoice form base class.
 *
 * @method Invoice getObject() Returns the current form's model object
 *
 * @package    corpon
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseInvoiceForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_invoice'         => new sfWidgetFormInputHidden(),
      'id_transaction'     => new sfWidgetFormInputText(),
      'auth_code'          => new sfWidgetFormInputText(),
      'message'            => new sfWidgetFormTextarea(),
      'result'             => new sfWidgetFormInputText(),
      'status'             => new sfWidgetFormInputCheckbox(),
      'is_paid'            => new sfWidgetFormInputCheckbox(),
      'invoice_amount'     => new sfWidgetFormInputText(),
      'shipping_amount'    => new sfWidgetFormInputText(),
      'tax_amount'         => new sfWidgetFormInputText(),
      'shipping_name'      => new sfWidgetFormInputText(),
      'shipping_last_name' => new sfWidgetFormInputText(),
      'shipping_company'   => new sfWidgetFormInputText(),
      'shipping_address'   => new sfWidgetFormInputText(),
      'shipping_state'     => new sfWidgetFormInputText(),
      'shipping_city'      => new sfWidgetFormInputText(),
      'shipping_zip'       => new sfWidgetFormInputText(),
      'billing_address'    => new sfWidgetFormInputText(),
      'billing_state'      => new sfWidgetFormInputText(),
      'billing_city'       => new sfWidgetFormInputText(),
      'billing_zip'        => new sfWidgetFormInputText(),
      'billing_phone'      => new sfWidgetFormInputText(),
      'billing_fax'        => new sfWidgetFormInputText(),
      'billing_email'      => new sfWidgetFormInputText(),
      'billing_name'       => new sfWidgetFormInputText(),
      'billing_last_name'  => new sfWidgetFormInputText(),
      'billing_company'    => new sfWidgetFormInputText(),
      'payment_date'       => new sfWidgetFormDate(),
      'created_at'         => new sfWidgetFormDateTime(),
      'id_user'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id_invoice'         => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_invoice')), 'empty_value' => $this->getObject()->get('id_invoice'), 'required' => false)),
      'id_transaction'     => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'auth_code'          => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'message'            => new sfValidatorString(array('max_length' => 300, 'required' => false)),
      'result'             => new sfValidatorInteger(array('required' => false)),
      'status'             => new sfValidatorBoolean(array('required' => false)),
      'is_paid'            => new sfValidatorBoolean(array('required' => false)),
      'invoice_amount'     => new sfValidatorNumber(),
      'shipping_amount'    => new sfValidatorNumber(),
      'tax_amount'         => new sfValidatorNumber(),
      'shipping_name'      => new sfValidatorString(array('max_length' => 50)),
      'shipping_last_name' => new sfValidatorString(array('max_length' => 50)),
      'shipping_company'   => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'shipping_address'   => new sfValidatorString(array('max_length' => 255)),
      'shipping_state'     => new sfValidatorString(array('max_length' => 75)),
      'shipping_city'      => new sfValidatorString(array('max_length' => 100)),
      'shipping_zip'       => new sfValidatorString(array('max_length' => 40)),
      'billing_address'    => new sfValidatorString(array('max_length' => 255)),
      'billing_state'      => new sfValidatorString(array('max_length' => 75)),
      'billing_city'       => new sfValidatorString(array('max_length' => 100)),
      'billing_zip'        => new sfValidatorString(array('max_length' => 40)),
      'billing_phone'      => new sfValidatorString(array('max_length' => 40)),
      'billing_fax'        => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'billing_email'      => new sfValidatorString(array('max_length' => 80)),
      'billing_name'       => new sfValidatorString(array('max_length' => 50)),
      'billing_last_name'  => new sfValidatorString(array('max_length' => 50)),
      'billing_company'    => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'payment_date'       => new sfValidatorDate(array('required' => false)),
      'created_at'         => new sfValidatorDateTime(),
      'id_user'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'))),
    ));

    $this->widgetSchema->setNameFormat('invoice[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Invoice';
  }

}
